package com.lsa.letcode.the33.searchInRotatedArrNoDupl;

import static org.junit.Assert.*;

import org.junit.Test;

public class SearchInRotatedArrNoDuplTest {

	@Test
	public void test() {
		test(new int[] { 3, 1 }, 1 , 1);
		test(new int[] { 1 }, 2 , -1);
		test(new int[] { 1 }, 1 , 0);
		test(new int[] {  }, 1 , -1);
		test(new int[] { 1, 2, 3, 4, 5, 6, 7, }, 3, 2);
		test(new int[] { 6, 1, 2, 3, 4, 5 }, 3, 3);
		test(new int[] { 6, 7, 1, 2, 3, 4, 5 }, 3, 4);
		test(new int[] { 5, 6, 7, 1, 2, 3, 4 }, 3, 5);
		test(new int[] { 4, 5, 6, 7, 1, 2, 3 }, 3, 6);
		test(new int[] { 3, 4, 5, 6, 7, 1, 2 }, 3, 0);
		test(new int[] { 2, 3, 4, 5, 6, 7, 1 }, 3, 1);
		//               0  1  2  3  4  5  6
	}

	private void test(int[] arr, int t, int expectedIdx) {
		Solution s = new Solution();
		int idx = s.search(arr, t);
		assertEquals(expectedIdx, idx);
	}
}
